<?php

namespace app\model;

use think\Model;

class Admin extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    // 定义自动写入时间戳
    protected $autoWriteTimestamp = true;

    // 定义软删除字段名
    protected $deleteTime = 'delete_time';

    public function role()
    {
        return $this->belongsTo(Role::class);
    }

    public function store()
    {
        return $this->belongsTo(Store::class);
    }

    public function bindRole($roleId)
    {
        $this->role_id = $roleId;
        $this->save();
    }

    public function bindStore($storeId)
    {
        $this->store_id = $storeId;
        $this->save();
    }
}
